Kinetis SDK API Reference Manual  1.0.0-beta
Freescale Semiconductor, Inc.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
OSC HAL driver

The section describes the programming interface of the OSC HAL driver. More...

Macros

#define kOscCapacitorMask   (OSC_CR_SC2P_MASK | OSC_CR_SC4P_MASK | OSC_CR_SC8P_MASK | OSC_CR_SC16P_MASK)
 Oscillator capacitor load configurations mask.
 

Enumerations

enum  osc_instance_t { kOsc0 = 0 }
 Oscillator instance. More...
 
enum  osc_capacitor_config_t {
  kOscCapacitor2p = OSC_CR_SC2P_MASK,
  kOscCapacitor4p = OSC_CR_SC4P_MASK,
  kOscCapacitor8p = OSC_CR_SC8P_MASK,
  kOscCapacitor16p = OSC_CR_SC16P_MASK
}
 Oscillator capacitor load configurations. More...
 

oscillator control APIs

void osc_hal_enable_external_reference_clock (osc_instance_t instance)
 Enables the external reference clock for oscillator. More...
 
void osc_hal_disable_external_reference_clock (osc_instance_t instance)
 Disables the external reference clock for oscillator. More...
 
void osc_hal_enable_external_reference_clock_in_stop_mode (osc_instance_t instance)
 Enables the external reference clock in stop mode. More...
 
void osc_hal_disable_external_reference_clock_in_stop_mode (osc_instance_t instance)
 Disables the external reference clock in stop mode. More...
 
void osc_hal_enable_capacitor_config (osc_instance_t instance, uint32_t capacitorConfigs)
 Enables the capacitor configuration for oscillator. More...
 
void osc_hal_disable_capacitor_config (osc_instance_t instance, uint32_t capacitorConfigs)
 Disables the capacitor configuration for specific oscillator. More...
 

OSC Hal Driver

Overview

The OSC module is a crystal oscillator. The module and the external crystal or resonator generate a reference clock for the MCU.The osc_hal provides a set of APIs used to access these SIM registers including enable/disable external reference clock and set the capacitor configurations.

Oscillator Control register access APIs

Each Oscillator only has one control register, OSCx_CR. It provides an external reference clock enable, external reference clock stop enable and the capacitor load configuration settings.Example of OSC HAL access APIs

#include "osc/hal/fsl_osc_hal.h"
// Enable the external reference clock
// Disable the external reference clock
#include "osc/hal/fsl_osc_hal.h"
// Enable the osc0 capacitor 2p and 8p
// Disable the osc0 capacitor 4p and 16p

Enumeration Type Documentation

Enumerator
kOsc0 

Oscillator 0.

Enumerator
kOscCapacitor2p 

2 pF capacitor load

kOscCapacitor4p 

4 pF capacitor load

kOscCapacitor8p 

8 pF capacitor load

kOscCapacitor16p 

16 pF capacitor load

Function Documentation

void osc_hal_enable_external_reference_clock ( osc_instance_t  instance)

This function enables the external reference clock output for the oscillator - that is the OSCERCLK. This clock is used by many peripherals. It should be enabled at an early system initialization stage to ensure the peripherals could select it and use it.

Parameters
instanceOscillator instance
void osc_hal_disable_external_reference_clock ( osc_instance_t  instance)

This function disables the external reference clock output for oscillator - that is the OSCERCLK. This clock is used by many peripherals. It should be enabled at an early system initialization stage to ensure the peripherals could select and use it.

Parameters
instanceOscillator instance
void osc_hal_enable_external_reference_clock_in_stop_mode ( osc_instance_t  instance)

This function enables the external reference clock (OSCERCLK) when MCU enters Stop mode.

Parameters
instanceOscillator instance
void osc_hal_disable_external_reference_clock_in_stop_mode ( osc_instance_t  instance)

This function disables the external reference clock (OSCERCLK) when MCU enters Stop mode.

Parameters
instanceOscillator instance
void osc_hal_enable_capacitor_config ( osc_instance_t  instance,
uint32_t  capacitorConfigs 
)

This function enables the specified capacitors configuration for the oscillator. This should be done in the early system level initialization function call based on system configuration.

Parameters
instanceOscillator instance
capacitorConfigCapacitor configurations. Combination of OSC_CR_SCxP_MASK
void osc_hal_disable_capacitor_config ( osc_instance_t  instance,
uint32_t  capacitorConfigs 
)

This function enables the specified capacitors configuration for the oscillator.

Parameters
instanceOscillator instance
capacitorConfigCapacitor configurations. Combination of OSC_CR_SCxP_MASK